package whu.cn.whushare.ui.common;

import android.app.Activity;
import android.view.View;

import whu.cn.whushare.ui.main.MyTabGroupActivity;
import whu.cn.whushare.ui.main.MyTabRecommendActivity;

/**
 * 文件名：MyRecommendReShowFragment
 * 描 述：
 * 作 者：胡平平
 * 时 间：2015/1/20
 */
public class MyRecommendReShowFragment extends BaseFragment{
    private MyTabRecommendActivity myTabRecommendActivity;

    @Override
    //当MyRecommendReShowFragment被添加到非MyTabRecommendActivity实例时抛出异常
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof MyTabRecommendActivity)
            myTabRecommendActivity= (MyTabRecommendActivity) activity;
        else
            throw new IllegalArgumentException("fragment used in wrong activity");
    }

    //获取顶部菜单条
    protected View getTopBar(View root, int topId) {
        View view = super.initTopBar(root, topId);
        mTopBar.goBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goBack( myTabRecommendActivity);
            }
        });
        return view;
    }

    //获取不带“返回”按钮的顶部菜单条
    protected View getTopBarWithoutBack(View root, int topId) {
        View view = super.initTopBar(root, topId);
        mTopBar.goBack.setVisibility(View.GONE);
        return view;
    }

    public void onReShow(MyTabRecommendActivity myTabRecommendActivity) {
    }

    public boolean goBack(MyTabRecommendActivity myTabRecommendActivity ) {
        myTabRecommendActivity.goBack();
        return false;
    }

}

